package com.goldgov.mobile;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.gtiles.components.securityworkbench.bean.SwbAuthUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.goldgov.kcloud.core.json.JsonQueryObject;
import com.goldgov.learnmanage.service.Course;
import com.goldgov.learnmanage.service.CourseQuery;
import com.goldgov.learnmanage.service.CourseService;
import com.goldgov.learnmanage.service.User;
import com.goldgov.learnmanage.service.UserQuery;
import com.goldgov.learnmanage.service.UserService;
import com.goldgov.login.web.model.LoginAuthUser;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

/** 
 * @ClassName: LearnManageController
 * @Description: TODO
 * @author MaN
 * @date 2018年7月9日 
 */

@RestController
@RequestMapping("/mobile/learnmanage")
@Api("流动党员接口")
public class LearnManageForMobileController {

	@Autowired
	private CourseService courseService;
	
	@Autowired
	private UserService userService;
	
	@GetMapping("/listPartyMember")
	@ApiOperation(value = "流动党员列表", notes ="")
	@ApiImplicitParams({@ApiImplicitParam(name = "searchOrgID", value = "机构id", paramType = "query"),
			 @ApiImplicitParam(name = "searchUserName", value = "姓名", paramType = "query"),
			 @ApiImplicitParam(name = "searchMember", value = "是否是流动党员", paramType = "query")})
	public JsonQueryObject<User> listPartyMember(@ApiIgnore UserQuery query,HttpServletRequest request){
		SwbAuthUser user=LoginAuthUser.getUserByAdmin(request);
		if(null==query.getSearchOrgID() || "".equals(query.getSearchOrgID())) {
			query.setSearchOrgCode(user.getScopeCode());
		}
		List<User> list=userService.getUserList(query);
		query.setResultList(list);
		return new JsonQueryObject<>(query);
	}
	
//	@RequestMapping("/listLearnSituation")
//	@ApiOperation(value = "流动党员学习情况", notes ="")
//	@ApiImplicitParams({@ApiImplicitParam(name = "searchUserID", value = "用户id", paramType = "query")})
//	public JsonQueryObject<Course> listLearnSituation(@ApiIgnore CourseQuery query,HttpServletRequest request){
//		List<Course> list=courseService.getCourseList(query);
//		query.setResultList(list);
//		return new JsonQueryObject<>(query);
//	}
	@RequestMapping("/listLearnSituation")
	@ApiOperation(value = "流动党员学习情况", notes ="")
	@ApiImplicitParams({@ApiImplicitParam(name = "searchUserID", value = "用户id", paramType = "query"),
			@ApiImplicitParam(name = "searchBeginDate", value = "开始时间", paramType = "query"),
			@ApiImplicitParam(name = "searchEndDate", value = "结束时间", paramType = "query"),
			@ApiImplicitParam(name = "searchCourseTime", value = "学习总时长", paramType = "query")})
	public JsonQueryObject<Course> listLearnSituation(@ApiIgnore CourseQuery query,HttpServletRequest request){
		List<Course> list=courseService.getCourseLearnList(query);
		query.setResultList(list);
		return new JsonQueryObject<>(query);
	}
}
